package com.ruoyi.project.pms.service;

import java.time.LocalDateTime;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.pms.mapper.PmsGoodsSpecificationMapper;
import com.ruoyi.db.pms.domain.PmsGoodsSpecification;
import com.ruoyi.db.pms.domain.query.PmsGoodsSpecificationQueryVo;

/**
 * 商品规格Service业务层处理
 *
 * @author ruoyi
 * @date 2020-04-21
 */
@Service
public class PmsGoodsSpecificationService
{
    @Autowired
    private PmsGoodsSpecificationMapper pmsGoodsSpecificationMapper;

    /**
     * 查询商品规格
     *
     * @param id 商品规格ID
     * @return 商品规格
     */
    public PmsGoodsSpecification selectPmsGoodsSpecificationById(Long id)
    {
        return pmsGoodsSpecificationMapper.selectPmsGoodsSpecificationById(id);
    }

    /**
     * 查询商品规格列表
     *
     * @param pmsGoodsSpecificationQueryVo 商品规格
     * @return 商品规格
     */
    public List<PmsGoodsSpecification> selectPmsGoodsSpecificationList(PmsGoodsSpecificationQueryVo pmsGoodsSpecificationQueryVo)
    {
        return pmsGoodsSpecificationMapper.selectPmsGoodsSpecificationList(pmsGoodsSpecificationQueryVo);
    }

    /**
     * 根据sid查询商品规格
     *
     * @author 张涛
     * @param sid 商品规格ID
     * @return 商品规格
     */
    public List<PmsGoodsSpecification> selectPmsGoodsSpecificationBySid(Long sid)
    {
        return (List<PmsGoodsSpecification>) pmsGoodsSpecificationMapper.selectPmsGoodsSpecificationBySid(sid);
    }

    /**
     * 新增商品规格
     *
     * @param pmsGoodsSpecification 商品规格
     * @return 结果
     */
    public int insertPmsGoodsSpecification(PmsGoodsSpecification pmsGoodsSpecification)
    {
        return pmsGoodsSpecificationMapper.insertPmsGoodsSpecification(pmsGoodsSpecification);
    }

    /**
     * 修改商品规格
     *
     * @param pmsGoodsSpecification 商品规格
     * @return 结果
     */
    public int updatePmsGoodsSpecification(PmsGoodsSpecification pmsGoodsSpecification)
    {
        pmsGoodsSpecification.setUpdateTime(LocalDateTime.now());
        return pmsGoodsSpecificationMapper.updatePmsGoodsSpecification(pmsGoodsSpecification);
    }

    /**
     * 批量删除商品规格
     *
     * @param ids 需要删除的商品规格ID
     * @return 结果
     */
    public int deletePmsGoodsSpecificationByIds(Long[] ids)
    {
        return pmsGoodsSpecificationMapper.deletePmsGoodsSpecificationByIds(ids);
    }

    /**
     * 删除商品规格信息
     *
     * @param id 商品规格ID
     * @return 结果
     */
    public int deletePmsGoodsSpecificationById(Long id)
    {
        return pmsGoodsSpecificationMapper.deletePmsGoodsSpecificationById(id);
    }
}
